package com.indiv.pmy.vector;

public class Vector2d {
	double i, j;
	
	public Vector2d() {
		i = j = 0.0;
	}
	
	public Vector2d(double _i, double _j) {
		i = _i;
		j = _j;
	}
	
	public void makeUnitVector() {
		double norm = norm();
		i = i/norm;
		j = j/norm;
	}
	
	public void scale(double _factor) {
		i = i*_factor;
		j = j*_factor;
	}
	
	public void scale(double _xFactor, double _yFactor) {
		i = i*_xFactor;
		j = j*_yFactor;
	}
	
	public double norm() {
		return Math.sqrt(Math.pow(i, 2) + Math.pow(j, 2));
	}
	
	public boolean isPerpendicular(Vector2d vector) {
		return (dotProduct(vector) == 0);
	}
	
	public double dotProduct(Vector2d vector) {
		return i*vector.i + j*vector.j;
	}
	
	public double getI() { return i; }
	public double getJ() { return j; }
	public void setI(double _i) { i = _i; }
	public void setJ(double _j) { j = _j; }
}
